package com.tianji.learning.mapper;

import com.tianji.api.dto.IdAndNumDTO;
import com.tianji.learning.domain.po.LearningRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 学习记录表 Mapper 接口
 * </p>
 *
 * @author yp
 * @since 2024-07-20
 */
public interface LearningRecordMapper extends BaseMapper<LearningRecord> {


    @Select(" SELECT lesson_id as id, count(*) as num from learning_record WHERE user_id = #{userId} AND finished =1 and finish_time > #{weekBeginTime} and finish_time < #{weekEndTime} GROUP BY lesson_id ")
    List<IdAndNumDTO> countLearnedSections(LocalDateTime weekBeginTime, LocalDateTime weekEndTime, Long userId);
}
